<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Api_Model_Comment
{
	private $comment_id;
	private $location_id;
	private $user_id;
	private $content;
	private $created_time;

	public function __construct($comment_row = null) {
		if(!is_null($comment_row) && $comment_row instanceof Zend_Db_Table_Row) {
			$this->comment_id = $comment_row->comment_id;
			$this->location_id = $comment_row->location_id;
			$this->user_id = $comment_row->user_id;
			$this->content = $comment_row->content;
			$this->created_time = $comment_row->created_time;
		}
	}

	public function __set($name, $value) {
		switch($name) {
			case 'comment_id':
				if(!is_null($this->comment_id)) {
					throw new Exception('Cannot update travel comment\'s id');
				}
				break;
			case 'location_id':
				if(!is_null($this->location_id)) {
					throw new Exception('Cannot update location\'s id');
				}
				break;
			case 'user_id':
				if(!is_null($this->user_id)) {
					throw new Exception('Cannot update user\'s id');
				}
				break;
			case 'content':
				if(!is_null($this->content)) {
					throw new Exception('Cannot update content');
				}
				break;
			case 'created_time':
				if(!is_null($this->created_time)) {
					throw new Exception('Cannot update created_time');
				}
				break;
		}
		$this->$name = $value;
	}

	public function __get($name) {
		return $this->$name;
	}
}

